package com.liujit.mybatis.component;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.liujit.mybatis.utils.Snowflake;

/**
 * @author: liujun
 * @date: 2021/6/22 2:55 下午
 * @description: 自定义id生成策略
 */
public class CustomIdGenerator implements IdentifierGenerator {

    private Integer workerId = 1;

    private Integer dataCenterId = 1;

    @Override
    public Number nextId(Object entity) {
        long uid = new Snowflake(workerId, dataCenterId).nextId();
        return uid;
    }
}
